package com.mfangsoft.zhuangjialong.integration.product.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mfangsoft.zhuangjialong.common.context.UserContext;
import com.mfangsoft.zhuangjialong.integration.product.mapper.BrandClassifyEntityMapper;
import com.mfangsoft.zhuangjialong.integration.product.model.BrandClassifyEntity;
import com.mfangsoft.zhuangjialong.integration.product.service.BrandClassifyService;
@Service
public class BrandClassifyServiceImpl implements  BrandClassifyService {

	@Autowired
	private BrandClassifyEntityMapper brandClassifyEntityMapper ;
	@Override
	public Boolean addBrandClassify(BrandClassifyEntity brandClassifyEntity) {
		// TODO Auto-generated method stub
		
		brandClassifyEntity.setUser_id(UserContext.getCurrentUserId());
		brandClassifyEntityMapper.insertSelective(brandClassifyEntity);
		return true;
	}

	@Override
	public Boolean modifyBrandClassify(BrandClassifyEntity brandClassifyEntity) {
		// TODO Auto-generated method stub
		
		brandClassifyEntityMapper.updateByPrimaryKeySelective(brandClassifyEntity);
		return true;
	}

	@Override
	public Boolean removeBrandClassify(Long id) {
		// TODO Auto-generated method stub
		
		brandClassifyEntityMapper.deleteByPrimaryKey(id);
		return true;
	}

	@Override
	public List<BrandClassifyEntity> queryBrandClassifyByUserId(Long userId) {
		// TODO Auto-generated method stub
		return brandClassifyEntityMapper.selectByUserId(userId);
	}

	@Override
	public List<BrandClassifyEntity> queryBrandClassifyByUserId(Long userId, Long p_id) {
		// TODO Auto-generated method stub
		
		
		Map<String,Object> map = new HashMap<>();
		
		if(p_id.intValue()==-1){
			map.put("p_id", null);
		}else{
			map.put("p_id", p_id);
		}
			
		map.put("userId", userId);
		
		
		return brandClassifyEntityMapper.selectByUserIdAnPid(map);
	}

}
